package com.org.oracle.mongodb.entity;

import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.Data;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.data.mongodb.core.mapping.Field;

import java.io.IOException;
import java.util.List;

/**
 * @author suze
 * @date 2024/8/15
 * @time 14:12
 **/
@Document("circle_context")
@Data
public class CircleContext {
        @Field("circle_id")
        private String circleId;

        //这是全局唯一id 每一个内容元素只会有唯一对应的cmid 用来给评论元素进行匹配
        private String cmid;
        private Context context;
        private String id;
        private User user;
        private long type;



        public class User {
                private String avatar;
                private String userName;
                private String uuid;

                public String getAvatar() { return avatar; }
                public void setAvatar(String value) { this.avatar = value; }


                public String getUserName() { return userName; }
                public void setUserName(String value) { this.userName = value; }

                public String getuuid() { return uuid; }
                public void setuuid(String value) { this.uuid = value; }
        }
        public class Context {


                // 添加一个属性来存储图片集合
                private List<String> pictures; // 图片集合，这里使用字符串列表来存储图片URL
                private String record;//聊天记录
                private String word;//文字  可能要用到富文本

                // 以下是添加的属性的getter和setter方法
                public List<String> getPictures() {
                        return pictures;
                }

                public void setPictures(List<String> pictures) {
                        this.pictures = pictures;
                }

                public String getRecord() { return record; }
                public void setRecord(String value) { this.record = value; }

                public String getWord() { return word; }
                public void setWord(String value) { this.word = value; }

        }


        public Context getContext() { return context; }
        public void setContext(Context value) { this.context = value; }

        public String getid() { return id; }
        public void setid(String value) { this.id = value; }

        public User getUser() { return user; }
        public  void setUser(User value) { this.user = value; }

        public long getType() { return type; }
        public void setType(long value) { this.type = value; }

        @Override
        public String toString() {
                try {
                        ObjectMapper mapper = new ObjectMapper();
                        return mapper.writeValueAsString(this);
                } catch (IOException e) {
                        // Handle exception
                        e.printStackTrace();
                        return "Error converting CircleContext to JSON: " + e.getMessage();
                }
        }

}
